#include "DataStructure/Input/Constraint/SPCData.h"

#include "DataStructure/Common/Validation.h"
#include "DataStructure/Input/Solver/DOFDirections.h"

using namespace SG::DataStructure;

/**
 * @brief 获取从属自由度方向
 *
 * 返回从属自由度方向的实例。
 *
 * @return 从属自由度方向的实例
 */
SG::DataStructure::FEM::DofSet FEM::SPCData::GetIndexes () const
{
    return Int2VDofSet (m_c);
}

/// @brief 判断两个SPCData是否相等
/// @param a
/// @param b
/// @return
bool SG::DataStructure::FEM::operator== (const SPCData& a, const SPCData& b)
{
    if (a.m_sId != b.m_sId)
    {
        return false;
    }
    if (a.m_g != b.m_g)
    {
        return false;
    }

    if (a.m_c != b.m_c)
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_d, b.m_d))
    {
        return false;
    }
    if (a.m_domainId != b.m_domainId)
    {
        return false;
    }
    return true;
}

/// @brief 比较两个SPCData大小
/// @param SGDataA
/// @param SGDataB
/// @return
bool FEM::operator< (const SPCData& SGDataA, const SPCData& SGDataB)
{
    if (SGDataA.m_sId < SGDataB.m_sId)
    {
        return true;
    }
    if (SGDataA.m_sId > SGDataB.m_sId)
    {
        return false;
    }

    return SGDataA.m_g < SGDataB.m_g;
}